package com.neuedu.corejava.ch13;


/**
 * 
 * @author myh
 * @version 2019年8月14日下午5:18:34
 *
 */
public class ThreadExit extends Thread{
	private boolean running = true;
	@Override
	public void run() {
		while (running) {
			System.out.println("下载中.....");
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
			}	
		}
		System.out.println("子线程执行完毕");
	}
	
	public void stopDownload(){
		running = false;
	}
	
	public static void main(String[] args) {
		ThreadExit threadExit = new ThreadExit();
		threadExit.start();
		try {
			Thread.sleep(5000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		threadExit.stopDownload();
		System.out.println("主线程执行完毕");
	}
}
